package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionOperDemo {
    public static void main(String[] args) {
        Collection c1 = new ArrayList();
        c1.add("java");
        c1.add("c++");
        c1.add(".net");
        System.out.println(c1);

        Collection c2 = new ArrayList();
        c2.add("安卓");
        c2.add("水果");
        c2.add("花为");
        c2.add("大米");
        System.out.println(c2);

        c2.addAll(c1);
        System.out.println(c2);

        System.out.println(c1);


        Collection c3 = new ArrayList();
        c3.add("c++");
        c3.add("安卓");
        c3.add("java");
       // c3.add("php");//返回为false,因为c1里没有php


        System.out.println(c3);
        boolean contains = c1.containsAll(c3);//判断c1中是否包含c3中的所有元素
        System.out.println(contains);//true

/*
        c1.retainAll(c3);//取交集:c1中仅保留与c3所共有的元素
        System.out.println(c1);// java,c++
        System.out.println(c3);//c++,安卓,java*/


        //删交集:将c1中与c3共有的元素删除,c3不变
        c1.removeAll(c3);
        System.out.println(c1);//c1:.net
        System.out.println(c3);//c++,安卓,java



        Collection c = new ArrayList();
                c.iterator();
    }
}
